#pragma once

#include <stdint.h>
#include <map>
#include <vector>
#include <set>
#include <queue>
#include "MailDefine.h"
#include "AllProtocol.h"
#include "ComTypeDefine.h"

#pragma pack(push)
#pragma pack(1)


//活动状态
enum ACTIVITY_STATE
{
	AS_NOT_START = 0,	// 未开启
	AS_READY = 1,	// 准备
	AS_RUNNING = 2,	// 进行中
	AS_END = 3,	// 结束
	AS_TIME_OUT = 4		// 过期
};

//活动ID类型
enum ACTIVITY_TYPE_ID
{
	ATI_NONE = 0,
	ATI_SON_OF_KILLING = 1,		//杀戮之子
	ATI_PESTILENCE	= 2,		//瘟疫之战
	ATI_TOWER  = 3,				//塔防
	ATI_GUARD = 4,				//守护
	ATI_CLOUD = 5,				//云端试炼（工会副本）
	ATI_GOBLIN = 6,				//哥布林（工会活动）
	ATI_ANCIENT_ELF = 7,		//远古精灵（工会活动）
	ATI_WORLD_BOSS = 8,			//世界boss（巡游众神）
	ATI_CHAOS_DRAGON = 9,		//混沌之龙
	ATI_LOST_CITY = 10,			//遗失之城
	ATI_NOLIN_TREASURE = 11,	//诺林奇珍
	ATI_MONS_ATTACK_CITY = 12,	//怪物攻城
	ATI_ESCORT = 13,			//押镖
	ATI_ANSWER			= 14,	//世界答题
	ATI_DAILY_ANSWER    = 15,	//每日答题
	
};

enum ANSWER_TYPE_ID
{
	enAnswer_Type_None =0,
	enActivity_Type_Active =4,	//答题活动
};


//npc状态类型
enum ACT_NPC_STATE_TYPE
{
	ACT_NPC_STATE_TYPE_ALL = 1,		//全部
	ACT_NPC_STATE_TYPE_UPDATE = 2,	//更新
};

//活动NPC状态
enum ACT_NPC_STATE
{
	ACT_NPC_STATE_NONE = 0,			//无状态
	ACT_NPC_STATE_COUNT_DOWN = 1,	//倒计时
	ACT_NPC_STATE_TALK = 2,			//对话
	ACT_NPC_STATE_ANSWER_ERROR = 3,	//已答错
};

//远古精灵回复NPC
enum ACT_REPLY_NPC
{
	ACT_REPLY_NPC_GIVE_MONEY = 1,
	ACT_REPLY_NPC_KILL_MONS = 2,
};

//杀戮之子当前的状态
enum SON_OF_KILLING_STATE
{
	SOKS_NONE = 0,			//空状态
	SOKS_OWENER = 1,		//被人持有
	SOKS_DROPED = 2,		//掉落中
};

//遗失之城积分事件
enum EventLostCity
{
	EventLostCity_None,			
	EventLostCity_Convoy,		//护送(10s)
	EventLostCity_Kill,			//击杀
	EventLostCity_KillBoss,		//击杀恶龙图腾
	EventLostCity_ConvoyA,		//护送到己方据点
	EventLostCity_ConvoyB,		//护送到敌方据点
};

//遗失之城活动状态
enum LOST_CITY_STATE
{
	LOST_CITY_STATE_NONE = 0,				
	LOST_CITY_STATE_MONSTER_ALIVE = 1,		//恶龙图腾激活
	LOST_CITY_STATE_CONVOY = 2,				//旌旗护送
	LOST_CITY_STATE_FREE_KILL = 3,			//自由战
};

const uint32_t ACTIVITY_LOST_CITY_FLAG_DESTORY_TIME = 30;	//旌旗掉落后n秒内无人拾取消失
const uint32_t ACTIVITY_LOST_CITY_MONSTER_FRESH_TIME = 60;	//旌旗消失n秒后恶龙图腾将重新被刷新
const uint32_t ACTIVITY_LOST_CITY_ADD_CONVOY_SCORE = 10;	//护送n秒更新积分

const uint32_t ACTIVITY_SON_OF_KILLING_SYNC_POS_TIME = 10; //10秒更新一次

const uint32_t ACTIVITY_CHAOS_DRAGON_TITLE_SIZE = 5; //混沌之龙总共5个称号

const uint32_t ACTIVITY_LOST_CITY_MALL_BUY_TIMES_LIMIT = 5; //遗失之城商铺购买次数上限
const uint32_t ACTIVITY_LOST_CITY_TITLE_EFFECT_TIME = (7 * 2 * 24 * 3600);	//遗失之城限时称号持续时间

const uint32_t ACTIVITY_SON_OF_KILLING_ITEM_ID = 180109009; //杀戮之石ID

//杀戮之子lua配置
struct SonofKillingCfg
{
	uint32_t holdStoneTime;					//杀戮之石的胜利持有时间（秒）
	uint32_t broadcastTime;					//广播发布周期(秒) 
	uint32_t skillId;						//屏蔽坐骑功能skillId
	uint32_t safeAreaSkillId;				//杀戮之子进入安全区技能效果
	SonofKillingCfg()
	{
		holdStoneTime = 0;
		broadcastTime = 0;
		skillId = 0;
		safeAreaSkillId = 0;
	}
};

//瘟疫之战lua配置
struct PestilenceCfg 
{
	int32_t totalNum;						//活动总人数
	int32_t injectNum;						//感染者人数
	int32_t surviveNum;						//生还者人数
	int32_t contiTime;						//持续时间(单位：秒)
	int32_t injectReplaceId;				//感染者替换外观的触发器ID
	int32_t injectReplaceSkillId;			//感染者替换替换技能的触发器ID
	int32_t surviveReplaceId;				//生还者替换外观的触发器ID
	int32_t surviveReplaceSkillId;			//生还者替换技能的触发器ID
	int32_t injectCovertId;					//感染者的转化技能ID
	int32_t injectItemId;					//感染者奖励物品ID
	int32_t surviveItemId;					//生还者奖励物品ID
	int32_t attendItemId;					//参与奖励物品ID(失败方)
	char szWinTopic[MAX_MAIL_TOPIC_LEN];	//胜利邮件主题
	char szAttendTopic[MAX_MAIL_TOPIC_LEN];	//参与邮件主题
	char szWinContent[MAX_MAIL_CONTENT_LEN];//胜利邮件内容
	char szAttendContent[MAX_MAIL_CONTENT_LEN];//参与邮件内容
	PestilenceCfg()
	{
		totalNum = 0;
		injectNum = 0;
		surviveNum = 0;
		contiTime = 0;
		injectReplaceId = 0;
		injectReplaceSkillId = 0;
		surviveReplaceId = 0;
		surviveReplaceSkillId = 0;
		injectCovertId = 0;
		injectItemId = 0;
		surviveItemId = 0;
		attendItemId = 0;
		memset(szWinTopic, 0, sizeof(szWinTopic));
		memset(szAttendTopic, 0, sizeof(szAttendTopic));
		memset(szWinContent, 0, sizeof(szWinContent));
		memset(szAttendContent, 0, sizeof(szAttendContent));
	}
	void Clear()
	{
		totalNum = 0;
		injectNum = 0;
		surviveNum = 0;
		contiTime = 0;
		injectReplaceId = 0;
		injectReplaceSkillId = 0;
		surviveReplaceId = 0;
		surviveReplaceSkillId = 0;
		injectCovertId = 0;
		injectItemId = 0;
		surviveItemId = 0;
		attendItemId = 0;
		memset(szWinTopic, 0, sizeof(szWinTopic));
		memset(szAttendTopic, 0, sizeof(szAttendTopic));
		memset(szWinContent, 0, sizeof(szWinContent));
		memset(szAttendContent, 0, sizeof(szAttendContent));
	}
};



//哥布林NPC状态
struct GoblinNpcState
{
	uint64_t npcCid;		//cid
	uint32_t areaId;		//刷新区域
	uint64_t startTime;		//开始时间
	int32_t state;			//状态 GOBLIN_NPC_STATE
	uint32_t teamId;		//对话的队伍ID
	uint64_t startTalk;		//开始对话的时间（玩家对话进入位面的时间是不计算在npc倒计时时间之内）
	GoblinNpcState()
	{
		npcCid = 0;
		areaId = 0;
		startTime = 0;
		state = ACT_NPC_STATE_NONE;
		teamId = 0;
		startTalk = 0;
	}
};

//哥布林偷取资金配置
struct GoblinStealCfg 
{
	int32_t level;
	int32_t minMoney;
	int32_t maxMoney;
	GoblinStealCfg()
	{
		level = 0;
		minMoney = 0;
		maxMoney = 0;
	}
};
//level - GebolinStealCfg
typedef unordered_map<int32_t, GoblinStealCfg> GoblinStealMap;

//哥布林活动配置
struct GoblinCfg
{
	int32_t maxNpcNum;	//最大npc数量
	int32_t curNpcNum;	//当前同时存在NPC数量
	uint32_t npcId;		//npcID
	int32_t lifeSec;	//生存时间 秒
	SET_UINT32 setArea;	//刷新区域
	MAP_UINT32_INT32 mapFreshMons;//刷怪 monsid - num
	uint32_t bossMonsId;//boss怪ID
	uint32_t bornAreaId;//boss怪出生区域ID
	GoblinStealMap mapSteal;//偷取资金 
	GoblinCfg()
	{
		clear();
	}
	void clear()
	{
		maxNpcNum = 0;
		curNpcNum = 0;
		npcId = 0;
		lifeSec = 0;
		setArea.clear();
		mapFreshMons.clear();
		bossMonsId = 0;
		bornAreaId = 0;
		mapSteal.clear();
	}
}; 


//远古精灵NPC状态
struct AncientElfNpcState
{
	uint64_t npcCid;		//cid
	uint32_t areaId;		//刷新区域
	uint64_t startTime;		//开始时间
	int32_t state;			//状态 
	uint64_t talkCid;		//正在对话的玩家CID
	int32_t  giveMoney;		//给予金币数量
	uint32_t questionId;	//题目ID
	int8_t elfType;			//精灵类型
	SET_UINT64 setAnswer;	//回答错误的玩家
	AncientElfNpcState()
	{
		npcCid = 0;
		areaId = 0;
		startTime = 0;
		state = ACT_NPC_STATE_NONE;
		talkCid = 0;
		giveMoney = 0;
		questionId = 0;
		elfType = 0;
		setAnswer.clear();
	}
};

//远古精灵怪物状态
struct AnCientElfMonsState 
{
	uint64_t monsCid;		//怪物CID
	uint32_t areaId;		//区域ID
	int8_t elfType;			//精灵类型
	AnCientElfMonsState()
	{
		monsCid = 0;
		areaId = 0;
		elfType = 0;
	}
};

//贪婪小精灵 给予金币奖励
struct GiveRewardCfg
{
	uint32_t itemId;
	int32_t minNum;
	int32_t maxNum;
	int32_t rate;
	GiveRewardCfg()
	{
		itemId = 0;
		minNum = 0;
		maxNum = 0;
		rate = 0;
	}
};
typedef vector<GiveRewardCfg> VecGiveRewardCfg;
//远古精灵怪物信息
struct AncientElfMonsCfg
{
	uint32_t cfgId;			//怪物或者NPC配置ID
	int32_t maxNum;			//最大数量
	int32_t curNum;			//当前存在的最大数量
	SET_UINT32 setArea;		//刷新区域
	SET_UINT32 setQuestion;	//题目ID
	int32_t giveGold;		//给予NPC金币数量
	VecGiveRewardCfg vecGiveReward;//给予金币奖励
	uint32_t freshMonsId;	//触发刷新的怪物ID

	AncientElfMonsCfg()
	{
		clear();
	}
	void clear()
	{
		cfgId = 0;
		maxNum = 0;
		curNum = 0;
		setArea.clear();
		setQuestion.clear();
		giveGold = 0;
		freshMonsId = 0;
		vecGiveReward.clear();
	}
};

//远古精灵lua配置
struct AncientElfCfg 
{
	AncientElfMonsCfg irritableElf;		//暴躁小精灵
	AncientElfMonsCfg troubleElf;		//捣蛋小精灵
	AncientElfMonsCfg sensitiveElf;		//敏感小精灵
	AncientElfMonsCfg eruditeElf;		//博学小精灵
	AncientElfMonsCfg greedElf;			//贪婪小精灵
	AncientElfCfg()
	{
		clear();
	}
	void clear()
	{
		irritableElf.clear();
		troubleElf.clear();
		sensitiveElf.clear();
		eruditeElf.clear();
		greedElf.clear();
	}
};

//混沌之龙配置
struct ChaosDragonCfg
{
	uint32_t averageLvPlayerNum;
	uint32_t bossLvLower;
	uint32_t mapId;
	int32_t posX;
	int32_t posY;
	int32_t posZ;
	VEC_UINT32 titleIds;
	uint32_t bossId;
	uint32_t topNum;
	uint32_t titleVaildTime;

	ChaosDragonCfg()
	{
		Rest();
	}

	~ChaosDragonCfg()
	{
		Rest();
	}

	void Rest()
	{
		averageLvPlayerNum = 0;
		bossLvLower = 0;
		mapId = 0;
		posX = 0;
		posY = 0;
		posZ = 0;
		titleIds.clear();
		bossId = 0;
		topNum = 0;
	}
};

//遗失之城配置
struct LostCityCfg
{
	uint32_t mapId;
	int8_t unionLv;
	uint32_t monsterId;
	uint32_t lightFlagId;			//光明旌旗掉落id
	uint32_t darkFlagId;			//黑暗旌旗掉落id
	uint32_t lightItemId;			//光明旌旗物品id
	uint32_t darkItemId;			//黑暗旌旗物品id
	uint32_t lightSkillId;			//光明光辉buff
	uint32_t darkSkillId;			//黑暗光辉buff
	uint32_t masterTitleId;			//遗失城主称号
	uint32_t nationalTitleId;		//遗失之民称号
	uint32_t revivalTime;
	uint32_t unionConvoyAAdd;
	uint32_t unionConvoyBAdd;
	uint32_t unionKillAdd;
	uint32_t charConvoyAdd;
	uint32_t charConvoyAddPer10s;
	uint32_t charKillAdd;
	uint32_t killBossAdd;
	uint32_t sendLength;		//传送距离
	uint32_t flagAreaId;		//旌旗护送区域
	Point3<float> monsterPos;
	Point3<float> dropAPos;
	Point3<float> dropBPos;
	uint32_t bossAreaId;		//刷怪区域
	uint32_t lightAreaId;		//光明据点区域
	uint32_t darkAreaId;		//黑暗据点区域
	VEC_UINT32 lightAreas;		//光明阵营加速区域
	VEC_UINT32 lightMonsters;	//光明阵营加速区域monster
	VecPoint3 lightPos;			//光明阵营加速区域pos
	VEC_UINT32 darkAreas;		//黑暗阵营加速区域
	VEC_UINT32 darkMonsters;	//黑暗阵营加速区域monster
	VecPoint3 darkPos;			//黑暗阵营加速区域pos

	Point3<float> lightHoldPos;	//光明据点pos
	Point3<float> darkHoldPos;	//黑暗据点pos
	uint32_t lightMonsterId;	//光明据点monster活动开始时创建(生成光明据点特效)
	uint32_t darkMonsterId;		//黑暗据点monster活动开始时创建(生成黑暗据点特效)
	uint32_t lightArrivalBuff;	//光明据点buff 护送角色抵达时触发
	uint32_t darkArrivalBuff;	//黑暗据点buff 护送角色抵达时触发

	LostCityCfg()
	{
		Reset();
	}
	~LostCityCfg()
	{
		Reset();
	}

	void Reset()
	{
		mapId = 0;
		unionLv = 0;
		monsterId = 0;
		lightFlagId = 0;
		darkFlagId = 0;
		lightItemId = 0;
		darkItemId = 0;
		lightSkillId = 0;
		darkSkillId = 0;
		masterTitleId = 0;
		nationalTitleId = 0;
		revivalTime = 0;
		unionConvoyAAdd = 0;
		unionConvoyBAdd = 0;
		unionKillAdd = 0;
		charConvoyAdd = 0;
		charConvoyAddPer10s = 0;
		charKillAdd = 0;
		killBossAdd = 0;
		sendLength = 0;
		flagAreaId = 0;
		bossAreaId = 0;
		lightAreaId = 0;
		darkAreaId = 0;
		lightAreas.clear();
		lightMonsters.clear();
		lightPos.clear();
		darkAreas.clear();
		darkMonsters.clear();
		darkPos.clear();

		lightMonsterId = 0;
		darkMonsterId = 0;
		lightArrivalBuff = 0;
		darkArrivalBuff = 0;
	}
};

//遗失之城角色积分信息
struct LostCityCharInfo
{
	string charName;
	uint64_t charId;
	uint32_t charLv;
	uint32_t convoyValue;	//护送积分
	uint32_t killValue;		//击杀积分
	uint32_t totalValue;	//当次活动总积分
	uint32_t buyTimes;		//遗失之城商铺购买次数
	bool isGet;				//是否已领取奖励
	LostCityCharInfo()
	{
		charName = "";
		charId = 0;
		charLv = 0;
		convoyValue = 0;
		killValue = 0;
		totalValue = 0;
		buyTimes = 0;
		isGet = false;
	}
};
typedef vector<LostCityCharInfo> LOSTCITYSOCRE_VEC;

//遗失之城离线角色称号信息
struct LostCityOfflineTitle
{
	uint32_t titleId;
	uint32_t startTime;
	LostCityOfflineTitle()
	{
		titleId = 0;
		startTime = 0;
	}
};
typedef map<uint64_t, LostCityOfflineTitle> LOSTCITYTITLE_MAP;

//遗失之城工会积分信息
struct LostCityUnionInfo
{
	uint32_t unionId;
	uint32_t score;
	LOSTCITYSOCRE_VEC scoreVec;
	LOSTCITYTITLE_MAP titleMap;
	LostCityUnionInfo()
	{
		Clear();
	}
	void Clear()
	{
		unionId = 0;
		score = 0;
		scoreVec.clear();
		titleMap.clear();
	}
};


//活动数据
struct ActData 
{
	uint32_t actId;		//活动ID
	int32_t state;		//活动状态 0 关闭，1 开启
	uint64_t beginTime; //开始时间，针对开启的活动
	uint64_t endTime;	//结束时间，针对开启的活动
	ActData()
	{
		actId = 0;
		state = 0;
		beginTime = 0;
		endTime = 0;
	}
};


///////////////////////////////////// 怪物攻城 /////////////////////////////////////
//怪物攻城宝箱怪
struct BoxMonsCfgInfo 
{
	uint32_t monsId;	//怪物ID
	int32_t nNum;		//数量
	uint32_t areaId;	//区域ID
	BoxMonsCfgInfo()
	{
		monsId = 0;
		nNum = 0;
		areaId = 0;
	}
};
// 剩余水晶怪数量 - BoxMonsCfgInfo
typedef unordered_map<int32_t, BoxMonsCfgInfo> BoxMonsCfgMap;

//据点怪配置
struct PointMonsCfgInfo 
{
	uint32_t monsId;
	float fx;
	float fy;
	float fz;
	PointMonsCfgInfo()
	{
		fx = 0.0f;
		fy = 0.0f;
		fz = 0.0f;
	}
};

typedef vector<PointMonsCfgInfo> VecPointMonsCfg;

//攻城怪配置
struct AttackMonsCfgInfo 
{
	int32_t monsMinLevel;	//怪物最小等级
	SET_UINT32 setMons;		//怪物列表
	int32_t totalMonsNum;	//怪物总数量
	int32_t perMonsNum;		//每次刷新的数量
	int32_t perMonsSec;		//刷新的间隔
	// boss和 大boss是可选的
	SET_UINT32 setBoss;		//boss id列表
	int32_t totalBossNum;	//boss 总数量
	int32_t perBossNum;		//每次刷新boss数量
	int32_t perBossSec;		//刷新boss间隔
	uint32_t bigBossId;		//大boss ID
	uint32_t totalBigBossNum;//大BOSS总数量，默认为1
	int32_t perBigBossSec;	//全部刷完之后间隔多久才开始刷新大boss
	AttackMonsCfgInfo()
	{
		clear();
	}
	bool brushFinishMons()
	{
		return (totalMonsNum <= 0);
	}
	bool brushFinishBoss()
	{
		return (totalBossNum <= 0);
	}
	bool brushFinshBigBoss()
	{
		return (totalBigBossNum <= 0);
	}
	bool brushFinshAll()
	{
		return (brushFinishMons() && brushFinishBoss() && brushFinshBigBoss());
	}
	void clear()
	{
		monsMinLevel = 0;
		setMons.clear();
		totalMonsNum = 0;
		perMonsSec = 0;
		perMonsNum = 0;

		setBoss.clear();
		totalBossNum = 0;
		perBossSec = 0;
		perBossNum = 0;

		bigBossId = 0;
		perBigBossSec = 0;
		totalBigBossNum = 0;
	}
};
//等级 - AttackMonsCfgInfo,这里等级需要有序的，所以用map
typedef map<int32_t, AttackMonsCfgInfo > AttackMonsCfgMap;

//单个攻城怪配置信息
struct AttackMonsSingleCfgInfo
{
	uint32_t monsId;	//怪物ID
	uint32_t areaId;	//区域
	int32_t monsNum;	//数量
	AttackMonsSingleCfgInfo()
	{
		monsId = 0;
		areaId = 0;
		monsNum = 0;
	}
};
typedef vector<AttackMonsSingleCfgInfo> VecAttackMonsSingle;
typedef unordered_map<int32_t, VecAttackMonsSingle> AttackMonsSingleMap;
//怪物攻城
struct MonsAttackCityCfg
{
	int32_t effectDay;				//生效时间
	int32_t ceilLev;				//根据前100平均等级 向上取的等级
	int32_t floorLev;				//根据前100平均等级 向下取的等级
	int32_t monsMinLev;				//怪物刷新的最低等级
	int32_t totalWave;				//怪物总波数
	int32_t waveSec;				//每一波怪刷新间隔
	VecAttackMonsSingle  vecCrystal;//水晶怪
	MAP_UINT32_UINT32 mapAreaLine;	//区域路径 areaid - lineid
	AttackMonsSingleMap  mapBoxMons;//宝箱怪
	AttackMonsCfgMap mapAttackMons;	//攻城怪
	VecPointMonsCfg vecPointMons;	//据点怪
	MonsAttackCityCfg()
	{
		Clear();
	}
	void Clear()
	{
		effectDay = 0;
		ceilLev = 0;
		floorLev = 0;
		monsMinLev = 0;
		totalWave = 0;
		waveSec = 0;
		vecCrystal.clear();
		mapAreaLine.clear();
		mapBoxMons.clear();
		mapAttackMons.clear();
		vecPointMons.clear();
	}
};




#pragma pack(pop)